package com.firefly.admin.common.utils;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import javax.annotation.PostConstruct;

@Component
public class RestUtil {

    private static RestTemplate restTemplate;
    @Autowired
    private RestTemplate service;

    @PostConstruct
    public void init() {
        restTemplate = service;
    }

    public static JSONObject get(String url) {
        return restTemplate.getForObject(url, JSONObject.class);
    }

    public static JSONObject post(String url, JSONObject param) {
        return restTemplate.postForObject(url, param, JSONObject.class);
    }
}
